<?php
namespace control;

/*
*会议室申请类
*/

class meetingApplyClass extends adIndexClass
{
    private const title = '会议室申请';
    /*列表-查询条件*/
    public function home()
    {
        return $this->room();
    }


    /**
     * 会议室申请图
     * @return string
     */
    public function room(): string
    {
        $toDay = $this->date;
        $data['html'] = <<<efo
<div style="width: 95%;margin: 10px auto;padding: 0 20px">选择空闲时段的会议室</div>
<div class="calendarBody">
<div class="calendarTitle"><span id="pre-button" class="pre-next-button" data-type="pre"><</span><span id="calendar-date" class="calendar-date">{$toDay}</span><input type="hidden"  name="toDate" value="$toDay"><span id="next-button" data-type="next" class="pre-next-button" style="margin-left: 10px"> ></span></div>
<div class="calendarContent">
</div>
</div>
<script>
 $(function() {
      request();
       laydate.render({elem:'#calendar-date',done: function(value, date, endDate){
           requestFromDate(value)
       }, trigger:'click'});
   $(".calendarContent ").on('click','.click-line td',function(e) {
      let edit = $(this).data('edit');
      if (edit ===1){
            let roomId = $(this).data('id');
            let datetime = $(this).data('date');
            layer('meetingRecord','roomModel',{roomId:roomId,datetime:datetime});
      }
   });
     $("#next-button,#pre-button").click(function() {
        request($(this));
     })
     function request(e){
         let type = e?e.data('type'):'';
         let date = $("[name='toDate']").val();
         $.post(root+'control/adIndex.html?cla=meetingRecord&fun=calendar',{type:type,date:date},function(res) {
            if(res.warn ==2){
                $(".calendarContent").empty().append(res.html);
                $(".calendar-date").html(res.data.date);
                $("[name='toDate']").val(res.data.date);
            }else{
                warn(res.warn);
            }
        },'json')
     }
     function requestFromDate(date){
         $.post(root+'control/adIndex.html?cla=meetingRecord&fun=calendar',{type:'date',date:date},function(res) {
            if(res.warn ==2){
                $(".calendarContent").empty().append(res.html);
                $(".calendar-date").html(res.data.date);
                $("[name='toDate']").val(res.data.date);
            }else{
                warn(res.warn);
            }
        },'json')
     }
 })

</script>
<style>
.calendarContent{
 width: 97%;
 margin: 0 auto;
 padding-bottom: 20px
}
.pre-next-button{
 cursor: pointer;
 margin-right: 10px;
 font-size: 19px;
 font-weight: bold
}
.calendar-date{
font-weight: bold;font-size: 17px
}
.calendarBody{
 width: 95%;
 border: 1px solid rgb(230, 230, 230);
 margin: 10px auto
}
.calendarTitle{
 width: 100%;
 height: 50px;
 text-align: center;
 line-height: 50px
}
.click-line td{
 cursor: pointer;
}
.choiceDiv{
  position: absolute;
 width: 170px;
 background-color: #FFFFFF;
 box-shadow: rgb(230 230 230) 5px 5px 3px;
}
.choiceDivNav{
 cursor: pointer;
 height: 35px;

}
.dayTable{
border-collapse: collapse;
    border-spacing: 0;
}
.dayTable td {
    border: 1px solid rgb(230, 230, 230);
    word-break: break-all;
}
.rest-day{
  background-color: #4C9CFB;
}
.no-edit{
background-color: #F8F8F8
}
.choiceDivNav ul li {
 float: left;
 width: 47%;
 text-align: center;
 padding: 5px 2px;
}

.show-li{
 border-bottom: 2px solid #4C9CFB;
}
.choice-content ul li{
  padding: 3px 15px;
}
.choice-content ul li:hover {
    cursor: pointer;
    background-color: rgb(230, 230, 230);
}
.cycle-content ul li{
  padding: 3px 15px;
}
.cycle-content ul li:hover {
    cursor: pointer;
    background-color: rgb(230, 230, 230);
}
.choice-content,.cycle-content{
display: none;
}
.showContent{
 display: block;
}
.blueBackGroundColor{
  background-color: #4C9CFB !important;
  color:white;
}
</style>
efo;

        //返回
        return $this->tab($data);
    }


}

